/**
 * Created by Administrator on 2018/5/9.
 */
import React from 'react'
import {
  Route,
  Link,
  Redirect
} from 'react-router-dom'
import App from './App';
import { connect } from 'react-redux'
import { logout } from './Auth.redux.js'
function first(){
  return (
      <div>1111111111</div>
  )
}

function scend(){
  return (
      <div>22222222222</div>
  )
}

function third(){
  return (
      <div>333333333333</div>
  )
}
class Dashboard extends React.Component{
  constructor(props){
    super(props)
  }

  render(){
    console.log(this.props)
    const app=(<div>
      { this.props.isAuth?<button onClick={this.props.logout}>注销</button>:null}
      <ul>
        <li>
          <Link to="/dashboard/">11</Link>
        </li>
        <li>
          <Link to="/dashboard/2">22</Link>
        </li>
        <li>
          <Link to="/dashboard/3">33</Link>
        </li>
      </ul>
      <Route path="/dashboard/" exact component={App}></Route>
      <Route path="/dashboard/2" exact component={scend}></Route>
      <Route path="/dashboard/3" exact component={third}></Route>
    </div>)
    const redirect = (<Redirect to="/login"></Redirect>)
    return this.props.isAuth?app:redirect
  }
}

const mapStatetoProps =(state)=>{
  return state.auth
}

const actionCreators = {logout}
Dashboard = connect(mapStatetoProps,actionCreators)(Dashboard)
export default Dashboard